package com.lwj.springbootvue.model.vo;

import com.lwj.springbootvue.model.User;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;



// 用户登录对象
@Data
@NoArgsConstructor
public class LoginUser implements UserDetails {

    private long id;
    private String token;// token
    private long loginTime; // 登录时间

    private User user;// 登录用户的信息


    public LoginUser(User user){
        this.user=user;
    }



    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return user.getPassword();
    }

    @Override
    public String getUsername() {
        return user.getUsername();
    }


    // 确保有setLoginTime方法
    public void setLoginTime(long loginTime) {
        this.loginTime = loginTime;
    }

    // 相应的getLoginTime方法
    public long getLoginTime() {
        return loginTime;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getToken() {
        return token;
    }


    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
